# -*- coding: utf-8 -*-
# @Author  : gaoyu
# @Time    : 2024/2/6 10:22 PM
# @Function:

class Parameter:
    def __init__(self):
        self.m_XE = None
        self.m_KE = None
        self.m_CR = None
        self.m_CG = None
        self.m_CI = None
        self.m_CS = None
        self.m_KI = None
        self.m_KG = None
        self.m_EX = None
        self.m_SM = None
        self.m_IM = None
        self.m_B = None
        self.m_WM = None
        self.m_C = None
        self.m_LM = None
        self.m_UM = None
        self.m_KC = None

    def ReadFromFile(self, StrPath):
        # 定义要保存每行内容的变量列表
        lines = []
        with open(StrPath + "/data/parameter.txt", 'r') as file:
            for line in file:
                line = line.strip()
                lines.append(line)
        # 输出结果
        for i, line in enumerate(lines):
            print("第{}行的内容为：{}".format(i + 1, line))

        self.m_KC = lines[0]
        self.m_UM = lines[1]
        self.m_LM = lines[2]
        self.m_C = lines[3]
        self.m_WM = lines[5]
        self.m_B = lines[6]
        self.m_IM = lines[7]
        self.m_SM = lines[9]
        self.m_EX = lines[10]
        self.m_KG = lines[11]
        self.m_KI = lines[12]
        self.m_CS = lines[14]
        self.m_CI = lines[15]
        self.m_CG = lines[16]
        self.m_CR = lines[17]
        self.m_KE = lines[18]
        self.m_XE = lines[19]

        print("self.m_KC", self.m_KC)
        print("self.m_IM", self.m_IM)
        print("self.m_CS", self.m_CS)
        print("self.m_XE", self.m_XE)


class State:
    def __init__(self):
        self.m_F = None
        self.m_EM = None
        self.m_P = None
        self.m_dt = None
        self.m_WU = 0.0
        self.m_Q = 0.0
        self.m_WL = 0.0
        self.m_WD = 0.0
        self.m_W = 0.0
        self.m_FR = 0.0
        self.m_S0 = 0.0
        self.m_QS = 0.0
        self.m_QI = 0.0
        self.m_QG = 0.0
        self.m_QU = 0.0
        self.m_O = 0.0

    def ReadFromFile(self, StrPath):
        """
        读取模型计算时段长，h
        Args:
            StrPath:

        Returns:

        """
        # 定义要保存每行内容的变量列表
        with open(StrPath + "/data/time.txt", 'r') as file:
            for line in file:
                self.m_dt = line.strip()
                break
            print("self.m_dt", self.m_dt)

    def SetInput(self, nt, nw, watershed):
        self.m_P = watershed.GetP(nt, nw);
        self.m_EM = watershed.GetEM(nt, nw);
        self.m_F = watershed.GetF(nw);


if __name__ == '__main__':
    Parameter = Parameter()
    Parameter.ReadFromFile(".")
    # 读取模型计算时段长，h
    State = State()
    State.ReadFromFile(".")
